package com.base.andlangcore.mvvm

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModel
import androidx.viewbinding.ViewBinding

/**
 * 基础的Activity
 */
abstract class AndLangActivity<VB : ViewBinding,VM : AndLangModel> : AppCompatActivity() {
    lateinit var vb: VB  //ViewBinding
    val vm: VM by lazy { getVM() }//ViewModel

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        vb = getViewBinding()
        setContentView(vb.root)
        initView()
        initData()
    }

    override fun onDestroy() {
        super.onDestroy()
    }

    //获取ViewBinding
    abstract fun  getViewBinding() : VB
    //获取ViewModel
    abstract fun getVM():VM

    abstract fun initView()
    abstract fun initData()
}